home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9501 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  4.2 KB

  1. Path: anvil.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++
  4. Subject: Re: C/C++ knocks the crap out of Ada
  5. Date: 1 Mar 1996 11:11:33 -0800
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4h7i55INNknq@anvil.ugrad.cs.ubc.ca>
  8. References: <JSA.96Feb16135027@organon.com> <4gvrffINNlqo@anvil.ugrad.cs.ubc.ca> <4h4j31$1ga3@watnews1.watson.ibm.com> <dewar.825640041@schonberg>
  9. NNTP-Posting-Host: anvil.ugrad.cs.ubc.ca
  10.  
  11. In article <dewar.825640041@schonberg>, Robert Dewar <dewar@cs.nyu.edu> wrote:
  12.  >(b) C is actually not in such good shape here, although the ANSI standard
  13.  >has been out for quite a while, the compliance with this standard is stlil
  14.  >by no means universal. For example, just a few months ago, I wrote soe
  15.  >code using the standard which used the returned value from sprintf. It
  16.  >worked fine on OS/2, but bombed on SunOS, whose C compiler library does
  17.  >something non-standard. OK, this sort of thing happens, but it was the
  18.  
  19. SunOS is an old operating system. SunSoft has since released Solaris, which has
  20. an ANSI development environment. They probably have available for SunOS
  21. programming tools which are also more modern---I have no idea.
  22.  
  23. It is a matter of historical development that C became popular well before its
  24. standardization, but that does not mean that the standard itself is in bad
  25. shape.
  26.  
  27.  >response of our local "C expert" that I found interesting, I was told
  28.  >"everyone knows that you should not use the returned value of sprintf
  29.  >if you are writing portable code". Of course the situation gets better
  30.  
  31. That's obviously false. Not everyone knows it, and poeple get tripped up.
  32.  
  33.  >here with time, and finally the ANSI C standard is starting to have some
  34.  >force.
  35.  
  36. Yes, some old environments have a sprintf() function that does not have an
  37. ANSI-compliant return value. The standard provides you a way to detect
  38. non-compliant systems:
  39.  
  40. The predefined pre-processor identifier __STDC__ is 1 in standard-conforming
  41. implementations. You can write a program so that it almost certainly fails to
  42. translate if this is not present.
  43.  
  44. Of course, this may not be satsifactory, since you want the program to work!
  45. And of course, the presence of the symbol does not guarantee that the compiler
  46. is conforming, due to the lack of an ``official'' validation suite.
  47.  
  48.  >(c) C is much less hostile to extensions than Ada (to validate Ada you have
  49.  >to sign a declaration that you have not implemented any extensions). What
  50.  >this means in practice is that you have to be more careful in C not to
  51.  >wander off into these extensions
  52.  
  53. Again, this is the advantage of having an official validation suite. Big point
  54. in Ada's favor, obviously.
  55.  
  56.  >There are many fronts to argue this general point on, but I am afraid you
  57.  >have, through not knowing Ada well, wandered into an area where Ada has
  58.  >very definitely got the upper hand (C++ is of course another matter entirely :-)
  59.  
  60. True. As I said before, I should not have mistakenly lumped Ada and C++ in the
  61. same category. It is extremely unfair!
  62.  
  63. Standardization notwithstanding, any language will allow you to write errnoeous
  64. programs, whose outcome could have dire consequences. I can write in Ada a
  65. function that computes something other than what I intend it to compute, as I
  66. can in C.
  67.  
  68. Whether I'm more or less likely to do it in C is more of a matter for religious
  69. debate. Competent software engineers can work with either one and produce
  70. correct, well-defined results according to the standards. In addition to that,
  71. all software has to be subject to rigorous quality control, especially
  72. safety-critical software. That means all kinds of component testing and code
  73. inspection!
  74.  
  75. However, consider: If your software complies with the standard for whatever
  76. language you are using, and can be shown to be free of error and due to some
  77. faut in the compiler the software fails, causing some damage or injury, you can
  78. still be considered liable if chose to use a compiler that wasn't validated,
  79. can you not? If it was certified, you can pass the blame to the implementors of
  80. the tools. This is where the advantage of an official certification mechanism
  81. is clear, from the point of view of the user of the programming tools.
  82. -- 
  83.  
  84.